package com.anjbo.controller.circle.presentation;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.anjbo.bean.presentation.CirclePresentationDto;
import com.anjbo.common.RespDataObject;
import com.anjbo.common.RespStatus;
import com.anjbo.common.RespStatusEnum;
import com.anjbo.service.presentation.CirclePresentationService;

/**
 * 分析报告
 * @author Administrator
 *
 */
@RequestMapping("/app/circle/presentation")
@Controller
public class CirclePresentationController {
	@Resource
	private CirclePresentationService circlePresentationService;
	
	@RequestMapping("/getList")
	@ResponseBody
	public RespDataObject<List<CirclePresentationDto>> getList(HttpServletRequest request, @RequestBody Map<String,Object> pramMap){
		RespDataObject<List<CirclePresentationDto>> resp = new RespDataObject<List<CirclePresentationDto>>();
		try {
			List<CirclePresentationDto> lists = circlePresentationService.selectCirclePresentationList(pramMap);
			resp.setData(lists);
		} catch (Exception e) {
			resp.setCode(RespStatusEnum.FAIL.getCode());
			resp.setMsg(RespStatusEnum.FAIL.getMsg());
			e.printStackTrace();
			return resp;
		}
		resp.setCode(RespStatusEnum.SUCCESS.getCode());
		resp.setMsg(RespStatusEnum.SUCCESS.getMsg());
		return resp;
	}
	
	@RequestMapping("/updateSeeCount")
	@ResponseBody
	public RespStatus updateSeeCount(HttpServletRequest request, @RequestBody Map<String,Object> pramMap){
		RespStatus rs = new RespStatus();
		circlePresentationService.updateSeeCount(pramMap);
		rs.setCode(RespStatusEnum.SUCCESS.getCode());
		rs.setMsg(RespStatusEnum.SUCCESS.getMsg());
		return rs;
	}
	
	@RequestMapping("/selectDetail")
	@ResponseBody
	public ModelAndView selectDetail(HttpServletRequest request,Map<String,Object> pramMap){
		ModelAndView view = new ModelAndView("/analysisReport/detail.ftl");
		pramMap.put("id", request.getParameter("id"));
		Map<String,Object> detailMap = circlePresentationService.selectDetailById(pramMap);
		view.addObject("detail", detailMap);
		return view;
	}
}
